package com.karateca.columbiaimports;

import java.util.List;
import java.util.Map;

/**
 * Keeps all the data from an import including series and DUA type B data.
 * @author Andres Dominguez
 */
public class ImportBean
{
    /** DUA URL. */
    private String link;
    /** Holds header values. */
    private Map<String, String> duaHeader;
    /** Holds individual series. */
    private List<Map<String, String>> series;
    /** Holds DUA type B values */
    private Map<String, String> duaB;

    /**
     * Creates a new instance of ImportBean.
     */
    public ImportBean()
    {
    }

    /**
     * Creates a new instance of ImportBean.
     * @param link import link.
     */
    public ImportBean(String link)
    {
        this.link = link;
    }

    /**
     * @return the link
     */
    public String getLink()
    {
        return link;
    }

    /**
     * @param link the link to set
     */
    public void setLink(String link)
    {
        this.link = link;
    }

    /**
     * @return the duaHeader
     */
    public Map<String, String> getDuaHeader()
    {
        return duaHeader;
    }

    /**
     * @param duaHeader the duaHeader to set
     */
    public void setDuaHeader(Map<String, String> duaHeader)
    {
        this.duaHeader = duaHeader;
    }

    /**
     * @return the series
     */
    public List<Map<String, String>> getSeries()
    {
        return series;
    }

    /**
     * @param series the series to set
     */
    public void setSeries(List<Map<String, String>> series)
    {
        this.series = series;
    }

    /**
     * @return the duaB
     */
    public Map<String, String> getDuaB()
    {
        return duaB;
    }

    /**
     * @param duaB the duaB to set
     */
    public void setDuaB(Map<String, String> duaB)
    {
        this.duaB = duaB;
    }

    @Override
    public boolean equals(Object obj)
    {
        if (obj instanceof ImportBean)
        {
            return ((ImportBean) obj).getLink().equals(this.link);
        }
        return false;
    }

    @Override
    public int hashCode()
    {
        int hash = 7;
        hash = 73 * hash + (this.link != null ? this.link.hashCode() : 0);
        return hash;
    }

    /**
     * Print bean contents to stdout.
     */
    public void printBean()
    {
        try
        {
            System.out.println("--------------------- Header");
            for (String key : getDuaHeader().keySet())
            {
                System.out.println(key);
            }
            System.out.println("--------------------- B");
            for (String key : getDuaB().keySet())
            {
                System.out.println(key);
            }
            System.out.println("--------------------- Serie");
            for (String key : getSeries().get(0).keySet())
            {
                System.out.println(key);
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
}
